<?php
include '../c/config.php';
$mysqli = new mysqli($dbhost, $dbuser, $dbpwd, $dbName);
if (!$mysqli->set_charset("utf8")) {printf("Error loading character set utf8: %s\n", $mysqli->error);}
$query=$mysqli->query("SELECT * FROM `ti` where nianji=2 and step=1  ");
$i=1;

$xuanze=array();
while ($list=$query->fetch_array()) {
    $xuanze[$i]=trim($list['dan']);
 
$i++;
}


$tian=array();
$query=$mysqli->query("SELECT * FROM `ti` where nianji=2 and step=2 limit 0,100 ");
$i=1;
while ($list=$query->fetch_array()) {
   $tian[$i]=array(
    'a' => trim($list['da']), 
    'b' => trim($list['db']), 
    );
 
 $i++;
}



$pan=array();
$query=$mysqli->query("SELECT * FROM `ti` where nianji=2 and step=3  ");
$i=1;
while ($list=$query->fetch_array()) {
   $pan[$i]=trim($list['dan']);
 
   $i++;
}

$getData=array(
   'xz' => $xuanze,
   'pan' => $pan,
   'tian' => $tian
);


var_dump($getData);
file_put_contents('zhongxues.txt', json_encode($getData));

$mysqli->close();
 